package Huihu.src.LQB;

import java.util.Scanner;

public class 数组排序 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数组的长度：");
        int n = scanner.nextInt();
        int[] arr = new int[n];
        System.out.println("请输入数组的数据：");
        StringBuilder str=new StringBuilder();
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        for (int k = 0; k < arr.length - 1; k++) {
            for (int m = 0; m < arr.length - k - 1; m++) {
                if (arr[m] > arr[m + 1]) {
                    int val = arr[m];
                    arr[m] = arr[m + 1];
                    arr[m + 1] = val;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            str.append(arr[i]+" ");
        }
        String s=new String();
        s= str.toString();
        System.out.println(s);
    }
}
